﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SMS.Domain.Model;
using SMS.Domain;

namespace SMS.Shell.Windows
{
    /// <summary>
    /// Interaction logic for CargoWindow.xaml
    /// </summary>
    public partial class CargoWindow : Window
    {
        private Cargo _cargo;

        public CargoWindow()
        {
            InitializeComponent();

            _cargo = new Cargo();
            _cargo.Id = Guid.NewGuid();
            this.DataContext = _cargo;
        }

        public CargoWindow(Cargo cargo)
        {
            InitializeComponent();

            _cargo = cargo;
            this.DataContext = _cargo;
        }

        private void _btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            Cargo cargo = this.DataContext as Cargo;
            if (new SmsService().StoreCargo(cargo))
            {
                DialogResult = true;
            }
        }

        private void _btnCancel_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }
    }
}
